package vcp.gui.utils;


import javax.swing.JButton;

import vcp.gui.components.VCPMenu;
import vcp.gui.components.VCPPanel;


import java.awt.GridLayout;
import java.awt.Insets;
import java.util.ArrayList;
import java.util.Iterator;

public class MenuBuilder {
	private VCPPanel menuContainer;
	private ArrayList<Object> components;
	private Iterator<Object> it;
	private Insets buttons ;
	private GridLayout layout;
	
	public MenuBuilder(Insets ins,GridLayout layout){		
		components = new ArrayList<Object>();
		this.buttons = ins;
		this.layout = layout;
	}
	
	public void addItem(Object comp){
		this.components.add(comp);
	}
	
	public VCPPanel getMenu(){
		initialize();
		return menuContainer;
	}
	
	private void initialize(){
		menuContainer = new VCPMenu();
		menuContainer.setLayout(layout);
		it = components.iterator();
		while(it.hasNext())
		{
			JButton btn = (JButton)it.next();
            btn.setMargin(buttons);
            menuContainer.add(btn);
		}	
	}
}
